﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Northwind.NET.FE.Reports
{
    public partial class InvoiceReport : Form
    {
        public InvoiceReport()
        {
            InitializeComponent();
        }

        private void InvoiceReport_Load(object sender, EventArgs e)
        {
            refreshReport();
            this.WindowState = FormWindowState.Maximized;  
        }

        private void PreviewButton_Click(object sender, EventArgs e)
        {
            refreshReport();
        }

        private void refreshReport()
        {
            int? OrderID = null;
            if (!string.IsNullOrEmpty(OrderIDTextBox.Text))
            {
                OrderID = Int32.Parse(OrderIDTextBox.Text);
            }
            this.invoiceReportTableAdapter.Fill(this.simpleReportsDataSet.InvoiceReportDataTable, OrderID);
            this.InvoiceReportViewer1.RefreshReport();
        }

        public void PreviewInvoice(int orderId)
        {
            OrderIDTextBox.Text = orderId.ToString();
            this.Show(); 
        }

    }
}
